package com.community.itelligentcommunity.community.communityProperty.service;

import com.community.itelligentcommunity.common.base.dao.GenericDao;
import com.community.itelligentcommunity.common.base.service.GenericService;
import com.community.itelligentcommunity.common.util.user.UserInfo;
import com.community.itelligentcommunity.community.communityProperty.dao.PatrolControlDao;
import com.community.itelligentcommunity.community.communityProperty.entity.PatrolControlInf;
import com.community.itelligentcommunity.community.communityProperty.entity.QueryPatrolControl;
import com.community.itelligentcommunity.sys.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor={IllegalArgumentException.class})
public class PatrolControlService extends GenericService<PatrolControlInf, QueryPatrolControl> {

    @Autowired
    private PatrolControlDao patrolControlDao;

    @Override
    protected GenericDao<PatrolControlInf, QueryPatrolControl> getDao() {
        return patrolControlDao;
    }

    @Override
    public boolean save(PatrolControlInf entity) throws Exception {
        //获得操作人相关信息
        User user = UserInfo.getUser();
        entity.setCreateMgrId(user.getId());
        entity.setCreateMgrName(user.getNickName());
        return super.save(entity);
    }

    @Override
    public boolean update(PatrolControlInf entity) throws Exception {
        //获得操作人相关信息
        User user = UserInfo.getUser();
        entity.setCreateMgrId(user.getId());
        entity.setCreateMgrName(user.getNickName());
        return super.update(entity);
    }
    public boolean updateManager(PatrolControlInf inf){
        boolean success =  patrolControlDao.updateManager(inf);
        return success;
    }
}
